package roleService

import (
	roleDto "news_for_deepseek_interface/dto/admin/system/role"
	"news_for_deepseek_interface/model"
	adminModel "news_for_deepseek_interface/model/admin"
)

func My(params roleDto.MyRequest) (*roleDto.MyResponse, error) {
	var adminWithGroupData []adminModel.AdminWithGroupStruct

	db := model.GetInstance().GetDB().Model(&adminModel.AdminWithGroupStruct{})
	if err := db.Where("admin_id = ?", params.AdminId).Find(&adminWithGroupData).Error; err != nil {
		return nil, err
	}

	response := &roleDto.MyResponse{
		RoleIds: make([]int, 0),
	}

	for _, v := range adminWithGroupData {
		response.RoleIds = append(response.RoleIds, v.AdminGroupId)
	}

	return response, nil
}
